// Copyright (C) 2012 Tanmay Sinha
// All rights reserved

package org.saakshar.content;

import static org.saakshar.utils.StringUtils.*;

/**
 * 
 * An object representing a label in the blog. This is really a wrapper for a
 * string now. The idea is that at some point in future we could add more meta
 * information for a label.
 * 
 * @author tanmay
 * 
 */
public class Label {

	private final String label;

	public Label(String label) {
		// TODO: Replace the precondition check with a common utility
		if (isBlank(label)) {
			throw new IllegalArgumentException(
					"Label cannot be a null or empty.");
		}
		this.label = label;
	}

	/**
	 * @return the label
	 */
	public String getLabel() {
		return label;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((label == null) ? 0 : label.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Label other = (Label) obj;
		if (label == null) {
			if (other.label != null)
				return false;
		} else if (!label.equals(other.label))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return label;
	}

}
